<script setup>
import {ref,defineProps,defineEmits} from "vue";
import router from "../../../router/index.js";
// 是否显示弹窗
const isTaskDialog = ref(false);
// 父类传子组件
const props=defineProps(['isTaskDialog']);
const emit=defineEmits(['close'])
isTaskDialog.value=props.isTaskDialog;

// 类型
const type=ref([ '签到','随堂练习','主题讨论','问卷']);

const radio=ref(0);


// 关闭弹窗
const handleCloseDialog=()=>{
  emit('close');
}
// 跳转到对应的创建任务页面
const handleGoCreateTask=(index)=>{
  console.log(index);
  if(index==0){
    router.push('/signin');
  }else if(index==1){
    router.push('/classpractice');
  }else if(index==2){
    router.push('/topicdiscuss');
  }else if(index==3){
    router.push('/questionnaire');
  }
  emit('close');
}

</script>

<template>
  <el-dialog v-model="isTaskDialog" title="选择任务类型" width="500"     align-center>
    <el-radio-group v-model="radio">
      <el-radio v-for="(item,index) in type" :value="index">{{type[index]}}</el-radio>
    </el-radio-group>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="handleCloseDialog">取消</el-button>
        <el-button type="primary" @click="handleGoCreateTask(radio)">
          确认
        </el-button>
      </div>
    </template>
  </el-dialog>
</template>
<style scoped lang="less">

</style>